from blog.models import Category, Post, Comment
from family.models import Album, Photo
from django.contrib import admin

class PostInline(admin.TabularInline):
    model = Post
    extra = 1

class PostAdmin(admin.ModelAdmin):
    fieldsets = [
        ('Post informations', {'fields': ['public', 'category', 'title', 'content']}),
        #('Date information', {'fields': ['created_at'], 'classes': ['collapse']}),
    ]
    list_display = ('title', 'public', 'content', 'created_at')
    list_filter = ['created_at']
    search_fields = ['title', 'content']
    date_hierarchy = 'created_at'
    ordering = ['-created_at']
admin.site.register(Post, PostAdmin)

class CategoryAdmin(admin.ModelAdmin):
    fieldsets = [
        ('Category informations', {'fields': ['name']}),
    ]
    inlines = [PostInline]
admin.site.register(Category, CategoryAdmin)

class CommentAdmin(admin.ModelAdmin):
    list_display = ('name', 'email', 'content', 'created_at')
    ordering = ['-created_at']
admin.site.register(Comment, CommentAdmin)

class AlbumAdmin(admin.ModelAdmin):
    list_display = ('name', 'created_at')
admin.site.register(Album, AlbumAdmin)

class PhotoAdmin(admin.ModelAdmin):
    list_display = ('name', 'album', 'user', 'created_at')
    ordering = ['name']
admin.site.register(Photo, PhotoAdmin)






